<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <!-- 设置页面的 基本路径，页面所有资源引入和页面的跳转全部基于 base路径 -->
    <base th:href="${#request.getContextPath()}+'/'">
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,doctor-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="Bookmark" href="/favicon.ico">
    <link rel="Shortcut Icon" href="/favicon.ico"/>

    <script type="text/javascript" th:src="@{/lib/html5shiv.js}"></script>
    <script type="text/javascript" th:src="@{/lib/respond.min.js}"></script>


    <link rel="stylesheet" type="text/css" th:href="@{/h-ui/css/H-ui.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/h-ui.admin/css/H-ui.admin.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/lib/Hui-iconfont/1.0.8/iconfont.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/h-ui.admin/skin/default/skin.css}" id="skin"/>
    <link rel="stylesheet" type="text/css" th:href="@{/h-ui.admin/css/style.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/lib/bootstrap/css/bootstrap.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/lib/bootstrap-table/bootstrap-table.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css}"/>


    <script type="text/javascript" th:src="@{/lib/DD_belatedPNG_0.0.8a-min.js}"></script>
    <script>DD_belatedPNG.fix('*');</script>

    <title>添加医生</title>
</head>
<body>
<article class="page-container" >
        <form  class="form form-horizontal"  th:action="${doctor eq null }  ?'doctor/insert':'doctor/update'" method="post" id="form-doctor-add">
            <input type="hidden" id="doctorId" value="" name="doctorId" th:value=" ${doctor != null} ? ${doctor.doctorId}">
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-3">用户名：</label>
                    <div class="formControls col-xs-8 col-sm-6">
                        <input type="text" class="input-text" th:value=" ${doctor != null} ? ${doctor.username}"
                               th:disabled="${doctor ne null}?'true'" id="username" name="username">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-3">密码：</label>
                    <div class="formControls col-xs-8 col-sm-6">
                        <input type="password" class="input-text"
                             id="password" name="password">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-3">确认密码：</label>
                    <div class="formControls col-xs-8 col-sm-6">
                        <input type="password" class="input-text"
                              name="password2">
                    </div>
                </div>

                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-3">姓名：</label>
                    <div class="formControls col-xs-8 col-sm-6">
                        <input type="text" class="input-text" th:value=" ${doctor != null} ? ${doctor.realname}"
                               placeholder="" id="realname" name="realname">
                    </div>
                </div>

                <div class="row cl">
                    <label class="form-label col-xs-3 col-sm-3">性别：</label>
                    <div class="formControls col-xs-3 col-sm-3">
                        <span class="select-box" style="width:150px;">
                            <select class="select"  name="gender" size="1">
                                <option value="">请选择性别</option>
                                <option th:selected="${doctor ne null}? (${doctor.gender} eq '男')" value="男">男</option>
                                <option th:selected="${doctor ne null}? (${doctor.gender} eq '女')" value="女">女</option>
                            </select>
                        </span>
                    </div>
                    <label class="form-label col-xs-3 col-sm-1">科室：</label>
                    <div class="formControls col-xs-3 col-sm-3">
                        <span class="select-box" style="width:150px;">
                            <select class="select"  name="deptName" size="1">
                                <option value="">请选择科室</option>
                                <option th:each="dept:${depts}" th:selected="${doctor != null} ? (${doctor.deptName} eq ${dept.deptName})" th:value="${dept.deptName}" th:text="${dept.deptName}"></option>
                            </select>
                        </span>
                    </div>
                </div>


                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-3">级别：</label>
                    <div class="formControls col-xs-8 col-sm-3">
                        <span class="select-box" style="width:150px;">
                            <select class="select"  name="level" size="1">
                                <option value="">请选择级别</option>
                                <option th:each="dictionary:${dictionarys}" th:selected="${doctor != null} ? (${doctor.level} eq ${dictionary.dictionaryName})" th:value="${dictionary.dictionaryName}" th:text="${dictionary.dictionaryName}"></option>
                            </select>
                        </span>
                    </div>
                    <label class="form-label col-xs-4 col-sm-1">职务：</label>
                    <div class="formControls col-xs-8 col-sm-3">
                        <span class="select-box" style="width:150px;">
                            <select class="select"  name="jobName" size="1">
                                <option value="">请选择职务</option>
                                <option th:each="job:${jobs}" th:selected="${doctor != null} ? (${doctor.jobName} eq ${job.jobName})" th:value="${job.jobName}" th:text="${job.jobName}"></option>
                            </select>
                        </span>
                    </div>
                </div>

                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-3">手机号：</label>
                    <div class="formControls col-xs-8 col-sm-6">
                        <input type="text" class="input-text" th:value=" ${doctor != null} ? ${doctor.phone}"
                               placeholder="" id="phone" name="phone">
                    </div>
                </div>

                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-3">年龄：</label>
                    <div class="formControls col-xs-8 col-sm-6">
                        <input type="text" class="input-text" th:value=" ${doctor != null} ? ${doctor.age}"
                               placeholder="" id="age" name="age">
                    </div>
                </div>


                <div class="row cl" id="doctor-expert" >
                    <label class="form-label col-xs-4 col-sm-3">医生擅长：</label>
                    <div class="formControls col-xs-8 col-sm-6">
                        <input type="text" class="textarea radius" style="height: 50px" th:value=" ${doctor != null} ? ${doctor.doctorExpert}"
                                 name="doctorExpert">
                    </div>
                </div>

                <div class="row cl" id="doctor-desc" >
                    <label class="form-label col-xs-4 col-sm-3">医生介绍：</label>
                    <div class="formControls col-xs-8 col-sm-6">
                        <input type="text" class="textarea radius" style="height: 50px" th:value=" ${doctor != null} ? ${doctor.doctorDesc}"
                                 name="doctorDesc">
                    </div>
                </div>

                <div class="row cl">
                    <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                        <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                    </div>
                </div>
        </form>


</article>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" th:src="@{/lib/jquery/1.11.3/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/lib/jquery.validation/1.14.0/jquery.validate.js}"></script>
<script type="text/javascript" th:src="@{/lib/jquery.validation/1.14.0/messages_zh.js}"></script>
<script type="text/javascript" th:src="@{/lib/jquery.validation/1.14.0/validate-methods.js}"></script>
<script type="text/javascript" th:src="@{/lib/layer/2.4/layer.js}"></script>
<script type="text/javascript" th:src="@{/h-ui/js/H-ui.min.js}"></script>
<script type="text/javascript" th:src="@{/h-ui.admin/js/H-ui.admin.js}"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" th:src="@{/lib/My97DatePicker/4.8/WdatePicker.js}"></script>
<script type="text/javascript" th:src="@{/lib/datatables/1.10.0/jquery.dataTables.min.js}"></script>
<script type="text/javascript" th:src="@{/lib/bootstrap-table/bootstrap-table.js}"></script>
<script type="text/javascript" th:src="@{/lib/bootstrap-table/bootstrap-table-zh-CN.min.js}"></script>

<!--业务-->
<script type="text/javascript">
    $(function () {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form-doctor-add").validate({
            rules: {
                username:{
                    required:true
                },
                password:{
                    required:true
                },
                password2:{
                  required:true,
                  equalTo:"#password"
                },
                gender:{
                  required:true
                },
                realname: {
                    required: true,
                    isChinese:true
                },
                deptName:{
                    required:true
                },
                jobName:{
                    required:true
                },
                level:{
                    required:true
                },
                phone:{
                    required:true,
                    isMobile:true
                },
                email:{
                    required:true,
                    email: true
                },
                age:{
                    required:true
                }

            },
            success: "valid",
            messages: {
                username:{
                    required:"用户名不能为空"
                },
                password:{
                    required:"密码不能为空"
                },
                password2:{
                    required:"确认密码不能为空",
                    equalTo:"两次输入密码不一致"
                },
                realname: {
                    required: "姓名不能为空",
                    isChinese:"姓名必须是汉字"
                },gender:{
                    required:"请选择性别"
                },
                deptName:{
                    required:"请选择科室"
                },
                jobName:{
                    required:"请选择职务"
                },
                level:{
                    required:"请选择级别"
                },
                phone:{
                    required:"手机号不能为空",
                    isMobile:"手机号不合法"
                },
                email:{
                    required:"邮箱不能为空",
                    email: "邮箱不合法"
                },
                age:{
                    required:"年龄不能为空"
                }
            },
            submitHandler: function (form) {
                $(form).ajaxSubmit(function (data) {
                    layer.msg(data.msg, {icon: data.code, time: 1000}, function () {
                        //操作成功刷新数据
                        if (data.code == 1) {

                            //刷新父页面表格
                            parent.refresh();
                            //关闭窗口
                            parent.layer.closeAll();
                        }
                    });
                });
               }
        });

        /*医生擅长，医生描述动态显示*/
        var doctor=$("#doctorId").val();
        console.log(doctor)
        if (doctor == ""){
            $("#doctor-expert").css("display","none");
            $("#doctor-desc").css("display","none");

        }else {
            $("#doctor-expert").css("display","block");
            $("#doctor-desc").css("display","block");

        }

    });

</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>